<template>
  <div class="processRecord">
    <p-table size="middle" bordered :pagination="false" 
    :columns="columns"
    :scroll="{x:1300}"
    :data-source="tableData">
    <template slot="scientificType" slot-scope="text">
      <span>{{text === '1'?'单盘贴片外协加工':'厂内科研工单'}}</span>
    </template>
    </p-table>
  </div>
</template>
<script>
import process from '@/api/process'
import moment from 'moment'
const columns = [
          {
            title: '任务编号',
            align: 'center',
            width:180,
            dataIndex: 'scientificOrder',
          },
          {
            title: '申请人',
            align: 'center',
            width:180,
            dataIndex: 'scientificPlease',
          },
          {
            title: '部门名称',
            align: 'center',
            width:180,
            dataIndex: 'dptno',
            customRender:(text)=>{
              if(!text){
                return ''
              }else{
                return text
              }
            },
          },
          {
            title: '联系方式',
            align: 'center',
            width:180,
            dataIndex: 'scientificContact',
          },
          {
            title: '项目编码',
            align: 'center',
            width:180,
            dataIndex: 'scientificno',
          },
          {
            title: '项目名称',
            align: 'center',
            width:180,
            dataIndex: 'scientificname',
          },
          {
            title: '科研分类',
            align: 'center',
            width:180,
            dataIndex: 'scientificClassification',
          },
          {
            title: '加工类型',
            align: 'center',
            width:180,
            dataIndex: 'scientificType',
            scopedSlots: {customRender: 'scientificType'},
          },
          {
            title: '名称',
            align: 'center',
            width:180,
            dataIndex: 'name',
          },
          {
            title: '需求完成时间',
            align: 'center',
            width:180,
            dataIndex: 'contentTime',
            customRender:(text)=>{
                return text?moment(text).format('YYYY-MM-DD'):'--'
            },
          },
          {
            title: '型号/图号（版号）',
            align: 'center',
            width:180,
            dataIndex: 'model',
          },
          {
            title: '计划开始时间',
            align: 'center',
            width:180,
            dataIndex: 'scientificStarttime',
            customRender:(text)=>{
                return text?moment(text).format('YYYY-MM-DD'):'--'
            },
          },
          {
            title: '实际物料齐套时间',
            align: 'center',
            width:180,
            dataIndex: 'scientificQitime',
            customRender:(text)=>{
                return text?moment(text).format('YYYY-MM-DD'):'--'
            },
          },
          {
            title: '当前状态',
            align: 'center',
            width:180,
            dataIndex: 'status',
            customRender:(text)=>{
                return text===-1?'完成':text===0?'待提交':text===1?'审批中':text===2?'待工艺评审':
                text===3?'待工艺给出供应商建议':text===4?'待采购评审':text===5?'待需求发布':'其他'
            },
          },
          {
            title: 'BOMreport',
            align: 'center',
            width:180,
            dataIndex: 'bomReport',
            scopedSlots: {customRender: 'bomReport'},
          },
          {
            title: '科研bom表',
            align: 'center',
            width:180,
            dataIndex: 'researchBom',
            scopedSlots: {customRender: 'researchBom'},
          },
          {
            title: '附件',
            align: 'center',
            width:180,
            dataIndex: 'accessory',
            scopedSlots: {customRender: 'accessory'},
          },
          {
            title: '创建人',
            align: 'center',
            width:180,
            dataIndex: 'createBy',
          },
          {
            title: '创建日期',
            align: 'center',
            dataIndex: 'createTime',
            width:180,
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            },
          },
          {
            title: '更新人',
            align: 'center',
            width:180,
            dataIndex: 'updateBy',
          },
          {
            title: '更新日期',
            align: 'center',
            width:180,
            dataIndex: 'updateTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            },
          },
        ]

export default {
  inject: ['processInstanceId', 'taskId'],
  data () {
    return {
      columns,
      moment,
      readStatusMap: {
        1: '未读',
        2: '已读'
      },
      windowSize: true,
      tableData: [
        /* {
          startTime: '创建时间',
          endTime: '处理时间',
          activityName: '节点名称',
          assigneeName: '执行人',
          readStatus: '1',
          operator: 'operator',
          comment: '处理意见',
        } */
      ],
      tableHeight: '450',
    }
  },
  computed: {},
  methods: {
    getList () {
      process.getExampleBusiness(
     this.processInstanceId,
      ).then(res => {
        this.tableData.push(res.data)
        this.tableData.forEach((el, i) => {
          el.key = i + 1 + ''
        })
      })
    },
  },
  mounted () {
    this.getList()
  }
}
</script>
<style lang="less">
.processRecord{
  overflow: hidden;
  .handing{
    color: #409EFD;
  }
  .title-line{
    font-size: 16px;
    margin: 30px 0 10px 0;
  }
}
</style>
